package Text32;

import java.util.*;

public class Main {
    static int N = 100010;
    static int[] a = new int[N];
    static long[] s = new long[N];
    static int[] cnt = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i] = in.nextInt();
            s[i] = s[i - 1] + a[i];
        }
        long res = 0;
        cnt[0] = 1;
        for (int r = 1; r <= n; r++) {
            int i = (int) (s[r] % k);
            res += cnt[i];
            cnt[i]++;
        }
        System.out.println(res);
    }
}
